import Vue from 'vue'
import VueRouter from 'vue-router'
import BarChart from '@/views/BarChart.vue'

const originPush = VueRouter.prototype.push;  //备份原push方法

VueRouter.prototype.push = function (location, resolve, reject) {
  if (resolve && reject) {    //如果传了回调函数，直接使用
    originPush.call(this, location, resolve, reject);
  } else {                     //如果没有传回调函数，手动添加
    originPush.call(this, location, () => { }, () => { });
  }
}


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'BarChart',
    component: BarChart
  },
  {
    path: '/lineChart',
    name: 'LineChart',
    component: () => import('@/views/LineChart.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
